package view;

import imageUtility.ImageData;



public class GuiAdapter implements IInfraGuiAdapter {

	private final String EMPTYIMAGE = "C:\\Users\\Oleg\\Desktop\\Study\\10000.HighDefinition.PNG.Icon.Pack\\Nuove Png\\TEMPLATE\\GLASS.png";
	private final int DIM = 3;
	private int x;
	private int y;
	private ImageData[][] matrix;
	
	public GuiAdapter(ImageData[][] matrix) {
		this.matrix = matrix;
	}
	
	@Override
	public void Init(int x, int y) {
		this.x = x;
		this.y = y;
	}

	
	
	@Override
	public String[][] moveLeft() {
		x--;
		return buildSubMatrix();
	}

	@Override
	public String[][] moveRight() {
		x++;
		return buildSubMatrix();
	}

	@Override
	public String[][] moveUp() {
		y++;
		return buildSubMatrix();
	}

	@Override
	public String[][] moveDown() {
		y--;
		return buildSubMatrix();
	}
	
	private String[][] buildSubMatrix() {
		System.out.println("X is : " + x + " Y is : " + y);
		String[][] imagePaths = new String[DIM][DIM];
		for (int i = 0; i < DIM; i++) {
			for (int j = 0; j < DIM; j++) {
				if (matrix[x-DIM/2+i][y-DIM/2+j] == null) {
					imagePaths[i][j] = EMPTYIMAGE;
				} else {
					imagePaths[i][j] = matrix[x-DIM/2+i][y-DIM/2+j].getImagePath();
				}
			}
		}
		return imagePaths;
	}

}
